import { UserProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    //共享数据
    state: {
        userInfo: {
            nickName: '',
            coin: 0,
            headImg: require('../../assets/img/userImg.f8bbec5e.png')
        },
        cartTotal: 0
    },
    mutations: {
        //修改是否显示登录模态框
        changeuserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        cchuserInfo(state) {
            state.userInfo = {
                nickName: '',
                coin: 0,
                headImg: require('../../assets/img/userImg.f8bbec5e.png')
            },
                state.cartTotal = 0
        }
    },
    actions: {
        async apichangeuserInfo(context) {
            let res = await UserProfilesAPI()
            context.commit("changeuserInfo", res.data)
        }
    }
}